<?php
class UserteamController extends Zend_Controller_Action{

	private $oLoggedInUser;

	public function init(){
		$this->_helper->layout->setLayout ( 'ground' );
		$this->oLoggedInUser = Default_Service_Auth::getLoggedInUser();

		/*if(!isset($this->oLoggedInUser)){
			$this->_helper->redirector("index","login","default");
		}*/
	}

	public function indexAction(){

		$id = $this->_getParam('id');

		$oMyTeam = UserTeamPeer::retrieveByPK($id);

		if($oMyTeam){

			$oTeamPlayers = $oMyTeam->getUserTeamPlayers(new criteria());

			$oTournament = TournamentPeer::retrieveByPK($oMyTeam->getTournamentId());

			$this->view->team = $oMyTeam;
			$this->view->teamPlayers = $oTeamPlayers;
			$this->view->tournament = $oTournament;
		}
		
		$criteria = new Criteria();
		$criteria->add(UserTeamPeer::USER_ID,$id,Criteria::EQUAL);
		$oTeams = UserTeamPeer::doSelect($criteria);
		//$oTeams = $this->oLoggedInUser->getUserTeams();

		$this->view->teams = $oTeams;
		$this->view->id    = $id;

	}
	


}